package cn.edu.sjtu.se.dslab.component.dp.parse;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @ClassName: DesignPatternBean
 * @Description: 解析设计模式成为一个bean
 * @author longshaohang
 * @date 2013-7-26 下午9:26:44
 *
 */
public class DesignPatternBean {
	//the name of the "name" attribute
	static final String NAME_ATTR = "name";
	//the name of the <design-pattern-label> label
	static final String LABEL = "design-pattern-label";
	//the name of the <properties> label
	static final String PROPERTIES = "properties";

	private String name;

	private String labelText;

	private List<Property> properties;

	public DesignPatternBean(){
		properties = new ArrayList<Property>();
	}

	public List<Property> getProperties() {
		return properties;
	}

	public void setProperties(List<Property> properties) {
		this.properties = properties;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLabelText() {
		return labelText;
	}

	public void setLabelText(String labelText) {
		this.labelText = labelText;
	}


	public Property getPropertyByName(String name) {
		for(Property p: properties){
			if (name.equals( p.getName()))
				return p;
		}
		return null;
	}

	public void print(){
		for (Property p: properties){
			System.out.print("property name= " + p.getName() + '\t');
			System.out.print("Label= " + p.getLabel() + '\t');
			System.out.print("Type= " + p.getType() + '\t');
			System.out.print("value= " + p.getValue() + '\n');
		}
	}
}

